package org.ym.thread.application.command;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;

/**
 * 线程池配置类
 * @author ym
 */
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
public class ThreadPoolCreateCommand {
    private static final Integer CORE_POOL_SIZE = 5;
    private static final Integer MAX_MUM_POOL_SIZE = 200;
    private static final Integer KEEP_ALIVE_TIME = 0;
    private static final Integer QUEUE_SIZE = 10240;
    private static final Integer EXPIRED_TIME = 24;
    /**
     * 核心线程数
     */
    private Integer corePoolSize;
    /**
     * 最大线程数
     */
    private Integer maximumPoolSize;
    /**
     * 当前线程超过核心线程数后，空闲线程存活时间,单位ms
     */
    private Integer keepAliveTime;
    /**
     * 线程任务缓存队列长度
     */
    private Integer queueSize;
    /**
     * 结果保存超期时间,单位小时
     */
    private Integer expiredTime;

    public Integer getCorePoolSize() {
        return corePoolSize == null ? CORE_POOL_SIZE : corePoolSize;
    }

    public Integer getMaximumPoolSize() {
        return maximumPoolSize == null ? MAX_MUM_POOL_SIZE : maximumPoolSize;
    }

    public Integer getKeepAliveTime() {
        return keepAliveTime == null ? KEEP_ALIVE_TIME : keepAliveTime;
    }

    public Integer getQueueSize() {
        return queueSize == null ? QUEUE_SIZE : queueSize;
    }

    public Integer getExpiredTime() {
        return expiredTime == null ? EXPIRED_TIME : expiredTime;
    }
}
